
// === uuMeta.array ===
// depend: uuMeta
/*
uuMeta.toUniqueArray([0, 1, 2, 3, 3, 2, 1, 0]) - return [0, 1, 2, 3]
uuMeta.toCompactArray([,,1,2,,]) - return [1, 2]
 */
(function uuMetaArrayScope() {

// uuMeta.toUniqueArray - make array from unique element
function toUniqueArray(ary) { // @param Array: source
                              // @return Array:
  ary = toCompactArray(ary);
  var rv = [], ri = -1, v, i = 0, j, iz = ary.length, f = 0;

  for (; i < iz; ++i) {
    v = ary[i];
    for (f = 0, j = i - 1; !f && j >= 0; --j) {
      f = (v === ary[j]);
    }
    !f && (rv[++ri] = v);
  }
  return rv;
}

// uuMeta.toCompactArray - Array compaction, trim null and undefined element
function toCompactArray(ary) { // @param Array: source
                               // @return Array:
  var rv = [], ri = -1, v, i = 0, iz = ary.length;

  for (; i < iz; ++i) {
    if (i in ary) {
      v = ary[i];
      (v !== null && v !== void 0) && (rv[++ri] = v);
    }
  }
  return rv;
}

// --- initialize ---

// --- export ---
uuMeta.toUniqueArray = toUniqueArray;
uuMeta.toCompactArray = toCompactArray;

})(); // uuMeta.array scope

